#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2020-12-07 8:54 上午
# @Author  : yangdy
# @File    : 2020-12-07.861.翻转矩阵后的得分
# @Software: PyCharmCE
from tools.my_methods import *


class Solution:
    def matrixScore(self, A: List[List[int]]) -> int:
        if not A:
            return 0
        ans, ll = len(A), len(A)
        for i in range(1, len(A[0])):
            a = sum(1 if (A[j][0] == 1 and A[j][i] == 1) or (A[j][0] == 0 and A[j][i] == 0) else 0 for j in range(ll))
            a = max(a, ll-a)
            ans = ans * 2 + a
        return ans

